#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
using namespace std;

int main()
{
    int fd = open("bite", O_RDWR | O_CREAT | O_APPEND, 0666);
    if(fd < 0)
        exit(1);
    const char* msg = "i like linux!";
    const char* msg2 = "linux so easy!";
    write(fd, msg, strlen(msg));
    //文件指针移到开头
    lseek(fd, 0, SEEK_SET);
    char buff[50];
    size_t end = read(fd, buff, strlen(msg)+strlen(msg2));
    buff[end] = '\0';

    cout << buff << endl;

    close(fd);

    return 0;
}
